package slowka;

import java.util.Vector;
import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.GroupLayout.SequentialGroup;

/**
 * Contains list of words that were answered wrong
 * @author ssobczak
 */
public class StatsPanel extends javax.swing.JPanel {

    /**
     * Creates new form StatsPanel
     * @param answers Suite containing words from test
     */
    public StatsPanel(QuestionsSuite answers) {
        initComponents(answers.getWrongAnswers());
    }

    /**
     * Creates the panel's components and writes statistics
     * @param wrongAnswers vector of questions with mistakes
     */
    private void initComponents(Vector<Question> wrongAnswers) {
        javax.swing.JLabel label;
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        setLayout(layout);

        ParallelGroup PG = layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING);
        SequentialGroup VG = layout.createSequentialGroup();

        for(Question q : wrongAnswers) {
            label = new javax.swing.JLabel();
            label.setText(q.getQuestion() + " : " + q.getMistakes());

            PG.addComponent(label, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE);

           VG.addComponent(label, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
        }

         layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(91, 91, 91)
                .addGroup(PG)
                .addContainerGap(109, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(VG)
        );
    }

}
